package StudentsManage;

import java.util.ArrayList;
import java.util.Scanner;

public class UpdateStu {
    public static void updateStu() {
        System.out.println("请输入你要修改的学生的学号");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();

        //判断是否有该学生
        ArrayList<Student> students = Student.students;
        int index = Student.getIndex(id, students);

        //存在该学生
        if (index != -1) {
            //输入修改信息
            System.out.println("请输入你要修改的学生的姓名");
            String name = sc.nextLine();
            sc.nextLine();
            System.out.println("请输入你要修改的学生的年龄");
            int age = sc.nextInt();
            sc.nextLine();
            System.out.println("请输入你要修改的学生的地址");
            String address = sc.nextLine();
            //修改学生信息
            students.get(index).name = name;
            students.get(index).age = age;
            students.get(index).address = address;
            System.out.println("修改成功");
        } else {//不存在该学生
            System.out.println("没有找到该学生");
        }

    }
}
